<%--
  Created by IntelliJ IDEA.
  User: zhuya
  Date: 2016/1/28
  Time: 16:45
  办事咨询 ----我的提问页面
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=utf-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta name="format-detection" content="telephone=no">
    <title>监管预约</title>
    <link rel="stylesheet" href="<c:url value="/resource/wechat/css/frozen.css"></c:url>">
    <link rel="stylesheet" type="text/css" href="<c:url value="/resource/wechat/css/main.css"></c:url>"/>
</head>
<body class="bg_fff" ontouchstart>
<section class="ui-container">

    <div class="jgyy_form">
        <form method="post" id="gatxForm">
            <h1>公安机关提讯、提解犯罪嫌疑人预约申请表</h1>
            <div class="row mart0">
                <label>警官姓名:</label>
                <div>
                    <input type="text" name="G_name" id="jgxm"/>
                </div>
            </div>
            <div class="row">
                <label>警号:</label>
                <div>
                    <input type="text" name="G_jh" id="jh"/>
                </div>
            </div>
            <div class="row">
                <label>手机号码:</label>
                <div>
                    <input type="text" title="G_phone" id="phone"/>
                </div>
            </div>
            <div class="row">
                <label>办案单位:</label>
                <div>
                    <input type="text" name="G_badw" id="badw"/>
                </div>
            </div>
            <div class="row">
                <label>预约事项:</label>
                <input type="radio" style="margin-left: 5px;" name="G_yysx" value="0" checked/> 提讯
                <input type="radio" style="margin-left: 5px;" name="G_yysx" value="1"/> 提解出所
            </div>
            <div class="row">
                <label>持有文书:</label>
                <div>
                    <input type="text" name="G_cyws" id="cyws"/>
                </div>
            </div>
            <h1>在押人员信息<img style="float:right;" width="120px" height="25px" src="<c:url value='/resource/images/gdfz_03.png'/>" onclick="addPersion()"/></h1>

            <div class="row">
                <label>姓名:</label>
                <div>
                    <input type="text" name="G_zyname" id="xingming"/>
                </div>
            </div>
            <div class="row">
                <label>性别:</label>
                <div>
                    <input type="radio" name="G_zyxb" checked="checked" value="男">男
                    <input type="radio" name="G_zyxb" style="margin-left: 10px;" value="女">女
                </div>
            </div>

            <div class="row">
                <label>身份证号:</label>
                <div>
                    <input type="text" name="G_zysfzh" id="shenfen"/>
                </div>
            </div>
            <div id="addPersion"></div>
            <div class="row">
                <label>在押看守所:</label>
                <div>
                    <input type="text" name="G_zykss" value="${orgName}" readonly="readonly"/>
                </div>
            </div>

            <div class="row">
                <label class="twoline">预约会见日期:</label>
                <div>
                    <%--<input type="date" name="G_yyhjrq" style="height: 36px; display: block" id="time"/>--%>
                    <select id="time" name="G_yyhjrq" style="height: 36px; display: block">
                        <c:forEach var="rq" items="${yyrq}">
                            <option value="${rq}">${rq}</option>
                        </c:forEach>
                    </select>
                </div>
            </div>
            <div class="row">
                <label>预约时间:</label>

                <div>
                    <input type="radio" style="margin-left: 5px;"  name="G_yysj" value="上午" checked/> 上午
                    <input type="radio" style="margin-left: 5px;"  name="G_yysj" value="下午"/> 下午
                </div>
            </div>
            <input type="hidden" name="userGuid" value="${member.guid}">
            <input type="hidden" name="caseNo" value="${caseNo}">  <%--公安提取案件编号  --%>
            <input type="hidden" name="tableName" value="Form_data_7jxem">
            <input type="hidden" name="appType"  value="5">
            <input type="hidden" name="orgId"  value="${orgId}">
            <input type="hidden" name="pt"  value="${pt}">
            <input type="hidden" name="persionXh" id="persionXh">
        </form>
        <div class="but_main">
            <%--<button class="ui-btn-lg ui-btn-danger lf50" onclick="_close()">
                关闭
            </button>--%>
            <button id="yuyue" class="ui-btn-lg ui-btn-primary lf50 marlf2" onclick="doSubmit();" style="width:96%;align:center">
                预 约
            </button>
        </div>
    </div>
</section>
<script src="<c:url value='/resource/js/jquery-2.0.min.js'/>"></script>
<script src="<c:url value="/resource/js/jquery.serializejson.min.js"></c:url>"></script>
<script>
    var arr=[];
    var i = 1;
    function addPersion(){
        i = i+1;
        arr.push(i);
        var html = '<div id="persion'+i+'">'+
                '<img src="<c:url value='/resource/images/icon_close.png'/>" onclick="removePersion('+i+')"/>'+
                '<div class="row"><label>姓名:</label><div>'+
                '<input type="text"  name="G_zyname'+i+'" id="xingming'+i+'"/></div></div>'+
                '<div class="row"><label>性别:</label><div>'+
                '<input type="radio" style="margin-left: 5px;" name="G_zyxb'+i+'" value="男" checked/> 男'+
                '<input type="radio" style="margin-left: 5px;" name="G_zyxb'+i+'" value="女"/> 女</div></div>'+
                '<div class="row"><label>身份证号:</label><div>'+
                '<input type="text" name="G_zysfzh'+i+'" id="shenfen'+i+'"/></div></div></div>';
        $("#addPersion").append(html);
    }

    function removePersion(index){
        arr.splice(jQuery.inArray(index,arr),1);
        //i = i-1;
        $("#persion"+index).remove();
    }

    function _close(){
        location.href = "<c:url value='/api/case/index'/>";
    }

    function doSubmit() {
        if($("#jgxm").val() == ""){
            alert("请输入警官姓名");
            return;
        }
        if($("#jh").val() == ""){
            alert("请输入警号");
            return;
        }
        if($("#phone").val() == ""){
            alert("请输入手机号码");
            return;
        }
        if($("#badw").val() == ""){
            alert("请输入办案单位");
            return;
        }
        if($("#cyws").val() == ""){
            alert("请输入持有文书");
            return;
        }

        if($("#xingming").val() == ""){
            alert("请输入在押人姓名");
            return;
        }

        if($("#shenfen").val() == ""){
            alert("请输入在押人身份证号");
            return;
        }

        for(var xh = 0; xh < arr.length; xh++){
            if($("#xingming"+arr[xh]).val() == ""){
                alert("请输入在押人姓名");
                return;
            }

            if($("#shenfen"+arr[xh]).val() == ""){
                alert("请输入在押人身份证号");
                return;
            }
        }
        $("#persionXh").val(arr);

        if($("#yana").val() == ""){
            alert("请输入在押看守所");
            return;
        }
        if($("#fanzui").val() == ""){
            alert("请输入在押人案由");
            return;
        }
        if($("#time").val() == ""){
            alert("请输入预约会见日期");
            return;
        }
        var form = $("#gatxForm").serializeJSON();
        $("#yuyue").attr("disabled","disabled");
        $.ajax({
            url: "<c:url value="/api/project/doarrangementJg"></c:url>",
            data: JSON.stringify(form),
            type: 'post',
            contentType: "application/json",
            success: function (resp) {
                if (resp["succ"]) {
                    alert("预约已提交");
                } else {
                    $("#yuyue").attr("disabled",false);
                    alert("提交失败");
                }
            },
            error: function (resp) {
                $("#yuyue").attr("disabled",false);
                alert("提交失败,请重新操作");
            }
        });

    }
</script>
</body>
</html>
